#include <stdio.h>

void bubble_sort(int num[], int len);

int main() {
	int len1 = 0;
	int len2 = 0;
	scanf("%d", &len2);
	scanf("%d", &len1);

	int num1[len1 + len2];
	for (int i = 0; i < len1; i++) {
		scanf("%d", &num1[i]);
	}
	int num2[len2];
	for (int i = 0; i < len2; i++) {
		scanf("%d", &num2[i]);
	}

	for (int i = len1; i < len1 + len2; i++) {
		num1[i] = num2[i - len1];
	}

	bubble_sort(num1, len1 + len2);

	for (int i = 0; i < len1 + len2; i++) {
		printf("%d ", num1[i]);
	}

	return 0;
}

void bubble_sort(int num[], int len) {
	for (int i = 0; i < len - 1; i++) {
		for (int j = 0; j <= i; j++) {
			if (num[j] > num[j + 1]) {
				int tmp = num[j];
				num[j] = num[j + 1];
				num[j + 1] = tmp;
			}
		}
	}
}